package com.example.springbasic.service;

import com.example.springbasic.event.MsgEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MsgService implements ApplicationEventPublisherAware {

    @Autowired
    public ApplicationEventPublisher applicationEventPublisher;

    public void register() {
        log.info("register success");
        applicationEventPublisher.publishEvent(new MsgEvent("after register,do something"));
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {

    }
}
